<?php
/*
	奖励中心
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$this->session('footernav','');
if($_RQ['op']=='main'){
	$return['setting']=$this->plugin_setting('page_setting');
	$diytitle=array('tagent','tshop','tmyshop','tcenter','tbecome','balance_button','tcommission','tcommission1','commission_total','commission_1','balance_total','balance_1','commission_1_1','commission_0','balance_2','balance_3','balance_pay','tcommission_detail','torder','tdown','tmydown','area_title','commission_area');
	foreach($diytitle as $v){
		$return['setting'][$v]=$return['setting'][$v.'2']?:$return['setting'][$v];
	}
	$return['xieyi']=$this->plugin_setting('xieyi');
	set_html('title',$return['pluginset']['title']?:'奖励中心');
	$member=pdo_get('jy_weishop_member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'merchid'=>0),array('level','viptime'));
	$basic=model('core/member')->basic($_SESSION['uid']);
	$member=array_merge($member,$basic);
	$member['fromuser']=pdo_getcolumn('core_members',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'fromuser');
	if($member['fromuser']){
		$member['agent']=model('core/member')->basic($member['fromuser']);
	}else{
		$member['agent']=array('nickname'=>'总店');
	}
	$return['ordernum']=0;
	$return['feenum1']=$this->count('feelog',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'type'=>1),'id');
	$return['feenum2']=$this->count('feelog',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'type'=>2),'id');
	$return['feenum3']=$this->count('feelog',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'type'=>3),'id');
	$member['mid']=$_SESSION['uid'];
	$mylevel=pdo_get('jy_weishop_member_level',array('id'=>$member['level'],'uniacid'=>$_SESSION['uniacid']));
	$member['leveltitle']=$mylevel['title']?:'普通会员';
	if($this->setting['biglevelid'] && $member['level']!=$this->setting['biglevelid']){
		$member['canapply']=1;
	}
	$return['member']=$member;
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']);
	$data=array();
	$data['commission_1']=$this->sum('feelog',$params,'fee');
	$data['commission_1num']=$this->count('feelog',$params,'id');
	$data['fee_1']=$this->sum('feelog',array('type'=>1,'uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'fee');
	$data['fee_1num']=$this->count('feelog',array('type'=>1,'uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'id');
	$data['fee_3']=$this->sum('feelog',array('type'=>3,'uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'fee');
	$data['fee_3num']=$this->count('feelog',array('type'=>3,'uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'id');
	$levels=array();
	$return['data']=$data;
	$apply=$this->get('apply',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	if($apply['status']>=3){
		$return['member']['canupvideo']=1;
	}
	$videomonthday=$this->model('member')->check_apply3($apply['id']);
	$return['videomonthday']=date('Y-m-d',$videomonthday);
	$sharelink='jy_newczfee/activity//fromuser='.$_SESSION['uid'];
	$return['sharedata']=array(
		'title'=>$return['pluginset']['share_title']?$return['pluginset']['share_title']:'活动页-新人体验区',
		'desc'=>$return['pluginset']['share_desc']?$return['pluginset']['share_desc']:'新人体验区！',
		'link'=>custom_url($sharelink,true),
		'imgUrl'=>tomedia($return['pluginset']['share_image'])
	);
	exi($return);
}
?>